<template>
	<uni-popup ref="popup" type="center" :is-mask-click="isMaskClick" @maskClick="handleMaskClick">
		<view class="popup">
			<view class="title">考试须知</view>
			<h4 style="text-align: center">补考次数：{{ countTip }}</h4>
			<view class="popup-center">
				<view>1、请自觉独自完成考试。</view>
				<view>2、考试一旦开始，考试倒计时不会停止，请在考试时长内一次性答完所有题目。</view>
				<view>3、如果考试过程中关闭窗口，考试倒计时不会停止。</view>
				<view>4、如果需要重启浏览器或APP，考试计时结束前可随时再次进入考试继续答题。</view>
				<view>5、考试倒计时截止时，或考试时间截止时，自动提交试卷，未答的题按0分计。</view>
			</view>
			<view class="popup-footer">
				<view class="popup-footer-2" @click="handleConfirm">我已明白考试须知，确认开始考试</view>
			</view>
		</view>
	</uni-popup>
</template>
<script>
	export default {
		props: {
			// 点击蒙层是否关闭
			isMaskClick: {
				type: Boolean,
				default: false,
			},
			modelValue: {
				type: Boolean,
				default: false,
			},
			type: {
				type: String,
				default: "primary",
			},
			examType: {
				type: String,
			},
			countTip: {
				type: String,
				default: "",
			},
		},
		data() {
			return {};
		},
		model: {
			prop: "modelValue",
			event: "update:modelValue",
		},
		created() {},
		emits: ["cancel", "confirm", "update:modelValue"],
		watch: {
			modelValue(newValue, oldValue) {
				if (newValue === oldValue) return;
				if (newValue) return this.open();
				this.close();
			},
		},
		computed: {
			isPrimary() {
				return this.type === "primary";
			},
		},
		methods: {
			open() {
				this.$refs.popup.open("center");
			},
			close() {
				this.$refs.popup.close();
			},
			// 确认
			handleConfirm() {
				this.$emit("confirm");
				this.$emit("update:modelValue", false);
				this.close();
			},
			handleMaskClick() {
				this.handleCancel();
			},
			handleCancel() {
				this.$emit("cancel");
				this.$emit("update:modelValue", false);
				this.close();
			},
		},
	};
</script>
<style scoped lang="scss">
	.popup {
		background: #fff;
		width: 650rpx;
		position: relative;
		background: #ffffff;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		opacity: 1;
		font-family: PingFang SC-Regular, PingFang SC;
	}

	.title {
		padding-top: 90rpx;
		text-align: center;
		font-size: 36rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #333333;
	}

	.popup-center {
		padding-top: 90rpx;
		padding-left: 30rpx;
		padding-right: 30rpx;
		text-align: left;
		font-size: 36rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #333333;
		padding-bottom: 180rpx;
	}

	.popup-img {
		width: 182rpx;
		height: 182rpx;
		position: absolute;
		z-index: 1;
		left: 50%;
		transform: translateX(-50%);
		top: -54rpx;
	}

	.popup-footer {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		font-size: 34rpx;
		padding: 0 50rpx;
		color: #454a5e;
		box-sizing: border-box;
		position: absolute;
		z-index: 1;
		left: 0;
		bottom: 40rpx;

		.popup-footer-1,
		.popup-footer-2,
		.popup-footer-3,
		.popup-footer-4 {
			width: 100%;
			height: 88rpx;
			text-align: center;
			border-radius: 44rpx 44rpx 44rpx 44rpx;
			line-height: 88rpx;
		}

		.popup-footer-1 {
			border: 1rpx solid #454a5e;
			width: 244rpx;
			height: 86rpx;
			line-height: 86rpx;
		}

		.popup-footer-2 {
			background: #88b4c4;
			color: #ffffff;
		}

		.popup-footer-3 {
			background: #c87c32;
			color: #ffffff;
		}

		.popup-footer-4 {
			border: 1rpx solid #454a5e;
			width: 244rpx;
			height: 86rpx;
			line-height: 86rpx;
		}
	}
</style>